import request from '@/config/axios'

export interface ModuleVO {
  id: number
  name: string
  code: string
}

// 查询模块列表
export const getModulePage = async (params) => {
  return await request.get({ url: `/system/module/page`, params })
}

export const getModuleList = async (params) => {
  return await request.get({ url: `/system/module/list`, params })
}

// 获取登陆用户的模块
export const getLoginUserModuleList = async () => {
  return await request.get({ url: `/system/module/list-login-user-modules` })
}

// 查询模块详情
export const getModule = async (id: number) => {
  return await request.get({ url: `/system/module/get?id=` + id })
}

// 新增模块
export const createModule = async (data: ModuleVO) => {
  return await request.post({ url: `/system/module/create`, data })
}

// 修改模块
export const updateModule = async (data: ModuleVO) => {
  return await request.put({ url: `/system/module/update`, data })
}

// 删除模块
export const deleteModule = async (id: number) => {
  return await request.delete({ url: `/system/module/delete?id=` + id })
}

// 导出模块 Excel
export const exportModule = async (params) => {
  return await request.download({ url: `/system/module/export-excel`, params })
}
